/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.test.messageboard.userranking.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.test.messageboard.userranking.model.MessageBoardUserRank;
import com.test.messageboard.userranking.model.MessageBoardUserRankModel;
import com.test.messageboard.userranking.model.MessageBoardUserRankSoap;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the MessageBoardUserRank service. Represents a row in the &quot;pa_MessageBoardUserRank&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.test.messageboard.userranking.model.MessageBoardUserRankModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link MessageBoardUserRankImpl}.
 * </p>
 *
 * <p>
 * Never modify or reference this class directly. All methods that expect a message board user rank model instance should use the {@link com.test.messageboard.userranking.model.MessageBoardUserRank} interface instead.
 * </p>
 *
 * @author nicolai
 * @see MessageBoardUserRankImpl
 * @see com.test.messageboard.userranking.model.MessageBoardUserRank
 * @see com.test.messageboard.userranking.model.MessageBoardUserRankModel
 * @generated
 */
public class MessageBoardUserRankModelImpl extends BaseModelImpl<MessageBoardUserRank>
	implements MessageBoardUserRankModel {
	public static final String TABLE_NAME = "pa_MessageBoardUserRank";
	public static final Object[][] TABLE_COLUMNS = {
			{ "userRankId", new Integer(Types.BIGINT) },
			{ "companyId", new Integer(Types.BIGINT) },
			{ "userId", new Integer(Types.BIGINT) },
			{ "userName", new Integer(Types.VARCHAR) },
			{ "createDate", new Integer(Types.TIMESTAMP) },
			{ "modifiedDate", new Integer(Types.TIMESTAMP) },
			{ "userScore", new Integer(Types.DOUBLE) },
			{ "isTrusted", new Integer(Types.BOOLEAN) }
		};
	public static final String TABLE_SQL_CREATE = "create table pa_MessageBoardUserRank (userRankId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,userScore DOUBLE,isTrusted BOOLEAN)";
	public static final String TABLE_SQL_DROP = "drop table pa_MessageBoardUserRank";
	public static final String ORDER_BY_JPQL = " ORDER BY messageBoardUserRank.userScore ASC";
	public static final String ORDER_BY_SQL = " ORDER BY pa_MessageBoardUserRank.userScore ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.test.messageboard.userranking.model.MessageBoardUserRank"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.test.messageboard.userranking.model.MessageBoardUserRank"),
			true);

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static MessageBoardUserRank toModel(
		MessageBoardUserRankSoap soapModel) {
		MessageBoardUserRank model = new MessageBoardUserRankImpl();

		model.setUserRankId(soapModel.getUserRankId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setUserScore(soapModel.getUserScore());
		model.setIsTrusted(soapModel.getIsTrusted());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<MessageBoardUserRank> toModels(
		MessageBoardUserRankSoap[] soapModels) {
		List<MessageBoardUserRank> models = new ArrayList<MessageBoardUserRank>(soapModels.length);

		for (MessageBoardUserRankSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.test.messageboard.userranking.model.MessageBoardUserRank"));

	public MessageBoardUserRankModelImpl() {
	}

	public long getPrimaryKey() {
		return _userRankId;
	}

	public void setPrimaryKey(long pk) {
		setUserRankId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_userRankId);
	}

	public long getUserRankId() {
		return _userRankId;
	}

	public void setUserRankId(long userRankId) {
		_userRankId = userRankId;
	}

	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public String getUserName() {
		if (_userName == null) {
			return StringPool.BLANK;
		}
		else {
			return _userName;
		}
	}

	public void setUserName(String userName) {
		_userName = userName;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public double getUserScore() {
		return _userScore;
	}

	public void setUserScore(double userScore) {
		_userScore = userScore;
	}

	public boolean getIsTrusted() {
		return _isTrusted;
	}

	public boolean isIsTrusted() {
		return _isTrusted;
	}

	public void setIsTrusted(boolean isTrusted) {
		_isTrusted = isTrusted;
	}

	public MessageBoardUserRank toEscapedModel() {
		if (isEscapedModel()) {
			return (MessageBoardUserRank)this;
		}
		else {
			return (MessageBoardUserRank)Proxy.newProxyInstance(MessageBoardUserRank.class.getClassLoader(),
				new Class[] { MessageBoardUserRank.class },
				new AutoEscapeBeanHandler(this));
		}
	}

	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
					MessageBoardUserRank.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	public Object clone() {
		MessageBoardUserRankImpl messageBoardUserRankImpl = new MessageBoardUserRankImpl();

		messageBoardUserRankImpl.setUserRankId(getUserRankId());

		messageBoardUserRankImpl.setCompanyId(getCompanyId());

		messageBoardUserRankImpl.setUserId(getUserId());

		messageBoardUserRankImpl.setUserName(getUserName());

		messageBoardUserRankImpl.setCreateDate(getCreateDate());

		messageBoardUserRankImpl.setModifiedDate(getModifiedDate());

		messageBoardUserRankImpl.setUserScore(getUserScore());

		messageBoardUserRankImpl.setIsTrusted(getIsTrusted());

		return messageBoardUserRankImpl;
	}

	public int compareTo(MessageBoardUserRank messageBoardUserRank) {
		int value = 0;

		if (getUserScore() < messageBoardUserRank.getUserScore()) {
			value = -1;
		}
		else if (getUserScore() > messageBoardUserRank.getUserScore()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		MessageBoardUserRank messageBoardUserRank = null;

		try {
			messageBoardUserRank = (MessageBoardUserRank)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = messageBoardUserRank.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{userRankId=");
		sb.append(getUserRankId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", userName=");
		sb.append(getUserName());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", userScore=");
		sb.append(getUserScore());
		sb.append(", isTrusted=");
		sb.append(getIsTrusted());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append(
			"com.test.messageboard.userranking.model.MessageBoardUserRank");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>userRankId</column-name><column-value><![CDATA[");
		sb.append(getUserRankId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userName</column-name><column-value><![CDATA[");
		sb.append(getUserName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userScore</column-name><column-value><![CDATA[");
		sb.append(getUserScore());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isTrusted</column-name><column-value><![CDATA[");
		sb.append(getIsTrusted());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _userRankId;
	private long _companyId;
	private long _userId;
	private String _userUuid;
	private String _userName;
	private Date _createDate;
	private Date _modifiedDate;
	private double _userScore;
	private boolean _isTrusted;
	private transient ExpandoBridge _expandoBridge;
}